var isType = function (obj) {
    var str = Object.prototype.toString.call(obj);
    var type = str.slice(8, str.length - 1);
    return type;
}


export const deepExtend = function (target, source) {
    // 检测参数
    if (!source || arguments.length !== 2) {
        return ;
    }
    var sourceType = isType(source),
        targetType = isType(target);

    // 基本类型
    if(targetType !== "Object" && targetType !== "Array" && targetType !== "Function") {
        target =  {};
    }

    if(sourceType !== "Object" && sourceType !== "Array" && sourceType !== "Function") {
        return target =  {};
    }


    // 遍历源对象中的属性
    for (var property in source) {
        var copy = source[property];
        if (source === copy) { continue; }
        // 将源对象中的属性复制到目标对象中
        if (isType(copy) === "Object") {
            // 递归
            target[property] = arguments.callee(target[property] || {}, copy);
        } else if (isType(copy) === "Array") {
            // 递归
            target[property] = arguments.callee(target[property] || [], copy);
        } else {
            target[property] = copy;
        }
    }
    // 返回目标对象
    return target;
}